import axios from 'axios';

const PREFIX = '/api/question-service'

/**
 * 用户登陆提交数据类型
 */
export interface queryPageType {
  difficultLevel?: string
  tag?: string,
  title?: string
}


/**
 * 问题分页查询
 * @param curretPage 
 * @param pageSize 
 * @param data 
 * @returns 
 */
export async function questionQueryPage(curretPage: number, pageSize: number, data: queryPageType) {
  return axios.post(`${PREFIX}/question/queryPage`, data, {
    params: {
      current: curretPage,
      size: pageSize,
    }
  });
}

/**
 * 删除问题
 * @param id 
 */
export async function questionDelete(value: number) {
  return axios.get(`${PREFIX}/question/delete`, {
    params: {
      id: value
    }
  })
}


/**
 * 删除问题
 * @param id 
 */
export async function questionQueryDetails(value: number) {
  return axios.get(`${PREFIX}/question/queryById`, {
    params: {
      id: value
    }
  })
}


/**
 * 新增题目
 * @param data 
 * @returns 
 */
export async function questionAdd(data: any) {
  return axios.post(`${PREFIX}/question/add`, data);
}

/**
 * 修改问题
 * @param data 
 * @returns 
 */
export async function questionEdit(data: any) {
  return axios.post(`${PREFIX}/question/edit`, data);
}